package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: 孙润达
 * @Date: 2022/1/7 18:26
 */
@RestController
@Api(tags = "暴露api接口")
@RequestMapping("/api/product")
public class ProductApiController {

    @Autowired
    private ManageService manageService;

    @ApiOperation("通过三级分类id查询分类信息")
    @GetMapping("/inner/getCategoryView/{category3Id}")
    public BaseCategoryView getCategoryView(@PathVariable Long category3Id ){
     BaseCategoryView baseCategoryView =manageService.getCategoryView(category3Id);
     return baseCategoryView;
    }
    @ApiOperation("获取sku最新价格")
    @GetMapping("/inner/getSkuPrice/{skuId}")
    public BigDecimal getSkuPrice(@PathVariable Long skuId ){
        BigDecimal bigDecimal= manageService.getSkuPrice(skuId);
     return bigDecimal;
    }
    @ApiOperation(" 根据skuId获取sku信息,根据skuId 查询图片列表集合")
    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId ){
        SkuInfo skuInfo=  manageService.getSkuInfo(skuId);
     return skuInfo;
    }
    @ApiOperation("根据spuId，查询spu_sale_attr_value（被选中的）")
    @GetMapping("/inner/getSpuSaleAttrValue/{skuId}/{spuId}")
    public List<SpuSaleAttr> getSpuSaleAttrListCheckBySku(@PathVariable Long skuId,
                                                          @PathVariable Long spuId){
        return manageService.getSpuSaleAttrListCheckBySku(skuId,spuId);
    }
    @ApiOperation("根据spuId，skuId 查询销售属性集合")
    @GetMapping("/inner/getSkuValueIdsMap/{spuId}")
    public Map getSkuValueIdsMap(@PathVariable Long spuId){
     return    manageService.getSkuValueIdsMap(spuId);
    }
    @ApiOperation("查询全部分类视图集合")
    @GetMapping("/inner/getBaseCategoryViewList")
    public List<BaseCategoryView> getBaseCategoryViewList(){
        return  manageService.getBaseCategoryList();
    }
    //3.查询品牌
    @GetMapping("/inner/getBaseTrademark/{tmId}")
    public BaseTrademark getBaseTrademark(@PathVariable Long tmId){
        return  manageService.getBaseTrademark(tmId);
    }
    // 5.平台属性集合
    @GetMapping("/inner/getSkuAttrValue/{skuId}")
    public  List<SkuAttrValue> getSkuAttrValue(@PathVariable Long skuId){
        List<SkuAttrValue> searchAttrList=  manageService.getSkuAttrValue(skuId);
        return searchAttrList;
    }

}
